package com.globalwave.common.web;

import com.globalwave.base.BaseAction;
import com.globalwave.common.ArrayPageList;
import com.globalwave.common.entity.SyncBatch;
import com.globalwave.common.entity.SyncBatchCriterion;
import com.globalwave.common.service.SyncBatchService;
import com.opensymphony.xwork2.Preparable;

public class SyncBatchAction extends BaseAction implements Preparable {

    private static final long serialVersionUID = 8582051849254108462L;
    
    private SyncBatchService syncBatchService ;
    private SyncBatch syncBatch ;
    private SyncBatchCriterion criterion ; 

    
    public String execute() throws Exception {    
        return this.list();    
    }
    
    public String list() throws Exception {      
        
        ArrayPageList<SyncBatch> pageList = 
            syncBatchService.query(criterion,pageIndex,pageSize,null) ;

        renderXML(pageList.asXML()) ;
        
        return null ;    
        
    }
    
    public String create()  throws Exception {              
        
        Object newSyncBatch = syncBatchService.create(syncBatch) ;

        renderXML(this.getSuccessCreateMessage(newSyncBatch).asXML()) ;
        
        return null;    
        
    }
    
    public String update()  throws Exception {     
        
        syncBatchService.update(syncBatch) ;

        renderXML(this.getSuccessUpdateMessage(syncBatch).asXML()) ;
        
        return null;    
        
    }
    
    public String delete()  throws Exception {
        if (ids == null) { 
            syncBatchService.delete(syncBatch) ;
        } else {
            syncBatchService.deleteAll(ids) ;
        }

        renderXML(this.getSuccessDeleteMessage().asXML()) ;
        
        return null;    
        
    }
    
    public void prepare() throws Exception {
        // Auto-generated method stub , donothing
        
    }
    
    public void setSyncBatchService(SyncBatchService syncBatchService) {
        this.syncBatchService = syncBatchService;
    }

    public SyncBatch getSyncBatch() {
        return syncBatch;
    }

    public void setSyncBatch(SyncBatch syncBatch) {
        this.syncBatch = syncBatch;
    }

    public SyncBatchCriterion getCriterion() {
        return criterion;
    }

    public void setCriterion(SyncBatchCriterion criterion) {
        this.criterion = criterion;
    }

}
